home *** CD-ROM | disk | FTP | other *** search
- /* ******************************************************************* */
- /* ** ** */
- /* ** ATKeyboard Version 4.0 ** */
- /* ** Copright (C) 1992-1994 by Thomas Dreibholz ** */
- /* ** All rights reserved ** */
- /* ** ** */
- /* ** Schoner-Steuerung ** */
- /* ** ** */
- /* ******************************************************************* */
-
- #include "ATkeyboard.h"
-
- extern struct Window *WindowPtr;
- extern struct TextFont *SchonerFont;
- extern struct Help *Help;
- extern struct Screen *SchonerScreen;
- extern struct Window *SchonerWindow;
- extern struct RastPort *SchonerRastPort;
- extern struct ViewPort *SchonerViewPort;
- extern struct Task *SchonerTask;
- extern struct Task *ColorCyclingTask;
- extern struct MsgPort *Port1,*Port2,*Port3;
- extern struct Message *Message1,*Message2;
- extern struct Einstellungen Einstellungen;
- extern struct NewScreen SchonerScreenDef;
- extern struct NewWindow SchonerWindowDef;
- extern struct Image MouseImage;
-
- EXTERN UBYTE *Buffer;
- EXTERN BOOL Online;
- EXTERN BOOL Schoner;
-
- EXTERN UWORD SchonerPalette[];
-
- VOID Ausgabe();
- VOID TesteEnde();
- VOID Warte();
- VOID SchonerProc();
- VOID ColorCyclingProc();
- VOID KontrolliereSchoner();
- VOID XMove();
- VOID XDraw();
- VOID XWritePixel();
- WORD Zufall();
- WORD rand();
-
-
- /* Warten, bis Grafik gewechselt werden muß */
- VOID Warte()
- {
- REGISTER UWORD a;
-
- ScreenToFront(SchonerScreen);
- for(a=0;a<Einstellungen.GrafikGeschwindigkeit;a++)
- {
- TesteEnde();
- Delay(50);
- ScreenToFront(SchonerScreen);
- }
- XMove(1,1);
- ClearScreen(SchonerRastPort);
- }
-
-
- /* Testen, ob Schoner beendet werden soll */
- VOID TesteEnde()
- {
- register struct Message *Message;
-
- Message=GetMsg(Port1);
- if(Message!=NULL)
- {
- CloseWindow(SchonerWindow);
- CloseScreen(SchonerScreen);
- SchonerScreen=NULL;
- ReplyMsg(Message);
- Exit(0);
- }
- }
-
-
- /* Bildschirmschoner-Task */
- #define ANZ_STERNE 100
-
- VOID SchonerProc()
- {
- REGISTER WORD a,i,rx,ry,co1,co2;
- REGISTER ULONG fa,x,fp0,fp1,fp2;
- REGISTER LONG m,n;
- ULONG f025,f0,f1,f3,f02,f56,f0125,f008,f004,f006,f007;
- UWORD ArrayX[ANZ_STERNE],ArrayY[ANZ_STERNE];
-
- geta4();
- if(Einstellungen.FarbrollPrioritaet<Einstellungen.SchonerPrioritaet)
- {
- Delay(25); /* Auf Farbroll-Task warten ... */
- }
- f025=XDiv(XFlt(40),XFlt(1));
- f0=XFlt(0);
- f1=XFlt(1);
- f3=XFlt(3);
- f56=XFlt(56);
- f02=XDiv(XFlt(50),XFlt(1));
- f0125=XDiv(XFlt(2),f025);
- f008=XDiv(XFlt(100),XFlt(8));
- f007=XDiv(XFlt(100),XFlt(7));
- f006=XDiv(XFlt(100),XFlt(6));
- f004=XDiv(XFlt(100),XFlt(4));
- FOREVER
- {
- if(Einstellungen.Gfx[0])
- {
- for(a=10;a<110;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=125;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XSin(x))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- rx=1;
- ry=125;
- co2=32;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry+XFix(XMul(XFlt(a),XCos(f0))));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co2);
- XDraw(rx,ry+XFix(XMul(fa,XCos(x))));
- x=XAdd(x,f025);
- co2++;
- if(co2>63) co2=32;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[1])
- {
- for(a=10;a<110;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=125;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XSin(x))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[2])
- {
- for(a=10;a<110;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=125;
- co2=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry+XFix(XMul(XFlt(a),XCos(f0))));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co2);
- XDraw(rx,ry+XFix(XMul(fa,XCos(x))));
- x=XAdd(x,f025);
- co2++;
- if(co2>31) co2=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[3])
- {
- for(a=10;a<110;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=80;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(XSin(x),XCos(x));
- XDraw(rx,ry+XFix(XMul(fa,XMul(fp0,XTan(x)))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[4])
- {
- for(a=10;a<110;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=70;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(XSin(x),XCos(x));
- fp1=XMul(XTan(x),XAtan(x));
- XDraw(rx,ry+XFix(XMul(fa,XMul(fp0,fp1))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[5])
- {
- for(a=10;a<90;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=125;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XMul(XAtan(x),XCos(x)))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[6])
- {
- for(a=10;a<80;a+=7)
- {
- x=f0;
- TesteEnde();
- rx=1;
- ry=125;
- co1=3;
- fa=XFlt(a);
- fp0=XSqrt(XMul(x,x));
- XMove(rx,ry+XFix(XMul(fa,XMul(XAtan(fp0),XSin(fp0)))));
- while(rx<318)
- {
- fp0=XSqrt(XMul(x,x));
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XMul(XAtan(fp0),XSin(fp0)))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[7])
- {
- for(a=10;a<90;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=125;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XCos(XMul(x,x));
- fp1=XAtan(XSqrt(x));
- XDraw(rx,ry+XFix(XMul(fa,XMul(fp0,fp1))));
- x=XAdd(x,f02);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[8])
- {
- for(a=10;a<90;a+=7)
- {
- TesteEnde();
- rx=1;
- ry=190;
- co1=3;
- x=f0;
- fa=XFlt(a);
- XMove(rx,ry);
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(x,x);
- fp1=XMul(XTan(x),XTan(x));
- fp2=XSqrt(XSqrt(XSqrt(fp1)));
- fp1=XMul(XSin(fp0),XCos(fp0));
- XDraw(rx,ry+XFix(XMul(fa,XMul(fp1,fp2))));
- x=XAdd(x,f0125);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[9])
- {
- x=f0;
- for(a=10;a<50;a+=3)
- {
- TesteEnde();
- rx=1;
- ry=120;
- co1=3;
- fa=XFlt(a);
- fp0=XMul(fa,XSin(x));
- fp1=XSin(fp0);
- XMove(rx-XFix(fp1),ry+XFix(fp0));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(fa,XSin(x));
- fp1=XAbs(XSin(fp0));
- XDraw(rx-XFix(fp1),ry+XFix(fp0));
- x=XAdd(x,f004);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- x=XAdd(x,f008);
- }
- Warte();
- }
- if(Einstellungen.Gfx[10])
- {
- x=f0;
- for(a=10;a<55;a+=3)
- {
- TesteEnde();
- rx=1;
- ry=120;
- co1=3;
- fa=XFlt(a);
- fp0=XMul(fa,XCos(x));
- fp1=XMul(XAtan(fp0),f3);
- XMove(rx-XFix(fp1),ry+XFix(fp0));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(fa,XCos(x));
- fp1=XMul(XAtan(fp0),f3);
- XDraw(rx-XFix(fp1),ry+XFix(fp0));
- x=XAdd(x,f004);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- x=XAdd(x,f007);
- }
- Warte();
- }
- if(Einstellungen.Gfx[11])
- {
- for(a=10;a<50;a+=3)
- {
- TesteEnde();
- rx=1;
- ry=120;
- co1=3;
- x=f0;
- fa=XFlt(a);
- fp0=XMul(fa,XCos(x));
- fp1=XMul(XAtan(fp0),XMul(XSin(fp0),XCos(fp0)));
- XMove(rx-XFix(fp1),ry+XFix(fp0));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- fp0=XMul(fa,XCos(x));
- fp1=XMul(XAtan(fp0),XMul(XSin(fp0),XCos(fp0)));
- XDraw(rx-XFix(fp1),ry+XFix(fp0));
- x=XAdd(x,f006);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[12])
- {
- for(a=10;a<100;a+=5)
- {
- TesteEnde();
- rx=1;
- ry=120;
- co1=32;
- x=XDiv(f56,XFlt(a-10));
- fa=XFlt(a);
- XMove(rx,ry+XFix(XMul(fa,XCos(x))));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XCos(x))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[13])
- {
- for(a=10;a<100;a+=5)
- {
- TesteEnde();
- rx=1;
- ry=120;
- co1=32;
- x=XDiv(f56,XFlt(a-10));
- fa=XFlt(a);
- XMove(rx,ry+XFix(XMul(fa,XCos(x))));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XCos(x))));
- x=XAdd(x,f025);
- co1++;
- if(co1>63) co1=32;
- rx++;
- }
- TesteEnde();
- rx=1;
- ry=120;
- co1=3;
- x=XDiv(f56,XFlt(a-10));
- fa=XFlt(a);
- XMove(rx,ry+XFix(XMul(fa,XSin(x))));
- while(rx<318)
- {
- SetAPen(SchonerRastPort,co1);
- XDraw(rx,ry+XFix(XMul(fa,XSin(x))));
- x=XAdd(x,f025);
- co1++;
- if(co1>31) co1=3;
- rx++;
- }
- }
- Warte();
- }
- if(Einstellungen.Gfx[14])
- {
- co1=3;
- for(i=0;i<ANZ_STERNE;i++)
- {
- ArrayX[i]=Zufall(1,319);
- ArrayY[i]=Zufall(1,255);
- SetAPen(SchonerRastPort,co1);
- XWritePixel(ArrayX[i],ArrayY[i]);
- co1++;
- if(co1>63) co1=3;
- }
- m=0; n=(Einstellungen.GrafikGeschwindigkeit*50)/ANZ_STERNE;
- while(m<n)
- {
- for(i=0;i<ANZ_STERNE;i++)
- {
- SetAPen(SchonerRastPort,0);
- XWritePixel(ArrayX[i],ArrayY[i]);
- SetAPen(SchonerRastPort,co1);
- ArrayX[i]=Zufall(1,319);
- ArrayY[i]=Zufall(1,255);
- XWritePixel(ArrayX[i],ArrayY[i]);
- Delay(3);
- TesteEnde();
- co1++;
- if(co1>63) co1=3;
- }
- m++;
- }
- XMove(1,1);
- ClearScreen(SchonerRastPort);
- }
- if(Einstellungen.Gfx[15])
- {
- Ausgabe(Copyright[0],80,3);
- Ausgabe(Copyright[1],110,3);
- Ausgabe(Copyright[2],140,10);
- Ausgabe(Copyright[3],170,5);
- Warte();
- }
- }
- }
-
-
- /* Text zentriert und leicht verzögert ausgeben */
- VOID Ausgabe(text,y,farbe)
- UBYTE *text;
- WORD y;
- UBYTE farbe;
- {
- REGISTER WORD laenge,x,i;
- REGISTER BOOL ende;
- UBYTE wort[2];
-
- laenge=strlen(text);
- x=(320-TextLength(SchonerRastPort,text,laenge))/2;
- XMove(x,y);
- for(i=0;i<laenge;i++)
- {
- wort[0]=text[i];
- SetAPen(SchonerRastPort,farbe);
- Text(SchonerRastPort,&wort,1L);
- x+=TextLength(SchonerRastPort,&wort,1L);
- XMove(x,y);
- farbe++;
- if(farbe>63) farbe=3;
- Delay(7);
- TesteEnde();
- }
- }
-
-
- /* Colorcycling-Task */
- VOID ColorCyclingProc()
- {
- REGISTER WORD i,help;
- register struct Message *Message;
-
- geta4();
- FOREVER
- {
- Message=GetMsg(Port2);
- if(Message!=NULL)
- {
- ReplyMsg(Message);
- return;
- }
- LoadRGB4(SchonerViewPort,&SchonerPalette,32L);
- help=SchonerPalette[31];
- for(i=31;i>3;i--) SchonerPalette[i]=SchonerPalette[i-1];
- SchonerPalette[3]=help;
- Delay(Einstellungen.FarbrollGeschwindigkeit);
- }
- }
-
-
- /* Prüfen, ob Schoner ein- oder ausgeschaltet werden muß */
- UBYTE *SchonerTaskName="ATKeyboard Schoner Task";
- UBYTE *ColorCyclingTaskName="ATKeyboard Color Cycling Task";
-
- VOID KontrolliereSchoner()
- {
- if((Schoner==TRUE)&&(SchonerScreen==NULL))
- {
- if(Einstellungen.SystemPAL==YES)
- {
- SchonerScreenDef.Height=256;
- SchonerWindowDef.Height=256;
- }
- else
- {
- SchonerScreenDef.Height=200;
- SchonerWindowDef.Height=200;
- }
- SchonerScreen=OpenScreen(&SchonerScreenDef);
- if(SchonerScreen!=NULL)
- {
- SchonerWindowDef.Screen=SchonerScreen;
- SchonerWindow=OpenWindow(&SchonerWindowDef);
- if(SchonerWindow!=NULL)
- {
- LeerePort(Port1);
- LeerePort(Port2);
- LeerePort(Port3);
- SchonerRastPort=SchonerWindow->RPort;
- SchonerViewPort=ViewPortAddress(SchonerWindow);
- if(SchonerFont) SetFont(SchonerRastPort,SchonerFont);
- SchonerTask=CreateProcess(SchonerProc,6500,SchonerTaskName,Einstellungen.SchonerPrioritaet);
- if(SchonerTask==NULL)
- {
- CloseWindow(SchonerWindow);
- CloseScreen(SchonerScreen);
- SchonerScreen=NULL;
- Schoner=FALSE;
- return;
- }
- ColorCyclingTask=CreateProcess(ColorCyclingProc,2500,ColorCyclingTaskName,Einstellungen.FarbrollPrioritaet);
- if(ColorCyclingTask==NULL)
- {
- PutMsg(Port1,Message1);
- WaitPort(Port3);
- GetMsg(Port3);
- SchonerScreen=NULL;
- Schoner=FALSE;
- return;
- }
- if(Einstellungen.Maus)
- {
- SetPointer(WindowPtr,&MouseImage,1,1,0,0);
- SetPointer(SchonerWindow,&MouseImage,1,1,0,0);
- }
- Say("the screen blanker is turned on");
- }
- else
- {
- CloseScreen(SchonerScreen);
- SchonerScreen=NULL;
- Schoner=FALSE;
- return;
- }
- }
- else
- {
- Schoner=FALSE;
- }
- }
- if((Schoner==FALSE)&&(SchonerScreen!=NULL))
- {
- ScreenToBack(SchonerScreen);
- ClearPointer(WindowPtr);
- PutMsg(Port2,Message2);
- WaitPort(Port3);
- GetMsg(Port3);
- PutMsg(Port1,Message1);
- WaitPort(Port3);
- GetMsg(Port3);
- Say("the screen blanker is turned off");
- Delay(30);
- }
- }
-
-
- /* Zufallszahl im Bereich min bis max zurückgeben */
- WORD Zufall(min,max)
- WORD min,max;
- {
- REGISTER WORD x;
-
- x=rand();
- x=(x % (max-min))+min;
- }
-
-
- /* Move-Befehl mit PAL/NTSC-Umrechnung */
- VOID XMove(x,y)
- UWORD x,y;
- {
-
- if(SchonerScreen->Height!=256)
- {
- Move(SchonerRastPort,x,(y*200)/256);
- }
- else
- {
- Move(SchonerRastPort,x,y);
- }
- }
-
-
- /* Draw-Befehl mit PAL/NTSC-Umrechnung */
- VOID XDraw(x,y)
- UWORD x,y;
- {
-
- if(SchonerScreen->Height!=256)
- {
- Draw(SchonerRastPort,x,(y*200)/256);
- }
- else
- {
- Draw(SchonerRastPort,x,y);
- }
- }
-
-
- /* WritePixel-Befehl mit PAL/NTSC-Umrechnung */
- VOID XWritePixel(x,y)
- UWORD x,y;
- {
-
- if(SchonerScreen->Height!=256)
- {
- WritePixel(SchonerRastPort,x,(y*200)/256);
- }
- else
- {
- WritePixel(SchonerRastPort,x,y);
- }
- }
-
-